import {
    PropertyDescription,
    PropertyDescriptionInterface, PropertyValue
} from './PropertyDescription'
import {__assign} from "tslib";

export const PropertyDescriptionTable = new Map<String, PropertyDescription>()
PropertyDescriptionTable.set(
    'tabCell',
    new PropertyDescription({
        props: [
            {
                name: 'header',
                default: '',
                group: 'common',
                desc: '选项卡名称',
                type: 'string'
            },
            {
                name: 'close',
                default: '',
                group: 'common',
                desc: '使能关闭',
                type: 'boolean'
            },
        ]
    })
)

const width: PropertyValue = {
    name: 'width',
    default: '',
    group: 'common',
    desc: '宽',
    type: 'number'
}

const height: PropertyValue = {
    name: 'height',
    default: '',
    group: 'common',
    desc: '高',
    type: 'number'
}

const label: PropertyValue = {
    name: 'label',
    default: '',
    group: 'common',
    desc: '文本描述',
    type: 'string',
    expr: true,
};
const labelAlign: PropertyValue = {
    name: 'labelAlign',
    default: '',
    group: 'common',
    desc: '描述对齐方式',
    type: ['left', 'right', 'center']
};
const labelWidth: PropertyValue = {
    name: 'labelWidth',
    default: undefined,
    group: 'common',
    desc: '文本宽度',
    type: 'number'
};
const gravity: PropertyValue = {
    name: 'gravity',
    default: 1,
    group: 'common',
    desc: '占位权重',
    type: 'number'
};
const hidden: PropertyValue = {
    name: 'hidden',
    default: false,
    group: 'common',
    desc: '隐藏',
    type: 'boolean',
    expr: true,
};
const readonly: PropertyValue = {
    name: 'readonly',
    default: false,
    group: 'common',
    desc: '只读',
    type: 'boolean',
    expr: true,
};
const disabled: PropertyValue = {
    name: 'disabled',
    default: false,
    group: 'common',
    desc: '禁用',
    type: 'boolean',
    expr: true,
};
const required: PropertyValue = {
    name: 'required',
    default: false,
    group: 'common',
    desc: '必填',
    type: 'boolean',
    expr: true,
};
const value: PropertyValue = {
    name: 'value',
    default: '',
    group: 'common',
    desc: '字段值',
    type: 'string',
    expr: true,
};
const prompt: PropertyValue = {
    name: 'prompt',
    default: '请输入',
    group: 'common',
    desc: '水印',
    type: 'string'
};
const validType: PropertyValue = {
    name: 'validType',
    default: '',
    group: 'common',
    desc: '校验类型',
    type: 'valid'
};
const metaId: PropertyValue = {
    name: 'metaId',
    default: '',
    group: 'bind',
    desc: '元数据ID',
    type: 'string'
};
const template: PropertyValue = {
    name: 'template',
    default: '',
    group: 'common',
    desc: 'HTML内容',
    type: 'string',
    expr: true,
}

const tooltip: PropertyValue = {
    name: 'tooltip',
    default: '',
    group: 'common',
    desc: '悬停提示',
    type: 'string'
}

const onClick: PropertyValue = {
    name: 'onClick',
    default: '',
    group: 'event',
    desc: '点击事件',
    eventParamter: [
        'sender: YvanUI.CtlButton',
        'e: any'
    ],
    eventDoc(vjson) {
        return (vjson['text']?vjson['text']:'按钮') + '被点击后触发';
    },
    type: 'string'
}

const onRowSelect: PropertyValue = {
    name: 'onRowSelect',
    default: '',
    group: 'event',
    desc: '行选中事件',
    eventParamter: [
        'sender: YvanUI.CtlGrid',
        'e: any'
    ],
    eventDoc(vjson) {
        return (vjson['ctlName']?vjson['ctlName']:'表格') + '被选中后触发';
    },
    type: 'string'
}

PropertyDescriptionTable.set(
    'rows',
    new PropertyDescription({
        props: [
            gravity,
            width
        ]
    })
)

PropertyDescriptionTable.set(
    'cols',
    new PropertyDescription({
        props: [
            gravity,
            height
        ]
    })
)


PropertyDescriptionTable.set(
    'gridColumns',
    new PropertyDescription({
        props: [
            {
                name: 'field',
                default: '',
                group: 'common',
                desc: '字段',
                type: 'string'
            },
            {
                name: 'title',
                default: '',
                group: 'common',
                desc: '字段名',
                type: 'string'
            },
            {
                name: 'metaId',
                default: '',
                group: 'common',
                desc: '元数据ID',
                type: 'string'
            },
            {
                name: 'width',
                default: '',
                group: 'common',
                desc: '宽',
                type: 'number'
            },
            {
                name: 'hidden',
                default: '',
                group: 'common',
                desc: '隐藏',
                type: 'boolean'
            },
            {
                name: 'formatter',
                default: '',
                group: 'common',
                desc: '格式化',
                type: 'string'
            },
            {
                name: 'filterable',
                default: '',
                group: 'common',
                desc: '筛选',
                type: 'boolean'
            },
            {
                name: 'sortable',
                default: '',
                group: 'common',
                desc: '排序',
                type: 'boolean'
            },
            {
                name: 'editable',
                default: '',
                group: 'common',
                desc: '编辑',
                type: 'boolean'
            },
            {
                name: 'editMode',
                default: '',
                group: 'common',
                desc: '编辑模式',
                type: 'string'
            },
            {
                name: 'editParams',
                default: '',
                group: 'common',
                desc: '编辑参数',
                type: 'object'
            }
        ]
    })
)
PropertyDescriptionTable.set(
    'window',
    new PropertyDescription({
        props: [
            {
                name: '_designMode',
                default: 'module',
                group: 'common',
                desc: '设计类型',
                type: ['none', 'dialog', 'scroll-dialog']
            },
            {
                name: 'title',
                default: '',
                group: 'common',
                desc: '对话框标题',
                type: 'string'
            },
            {
                name: 'modal',
                default: '',
                group: 'common',
                desc: '是否模态',
                type: 'boolean'
            },
            _.merge(_.cloneDeep(width), {default: 200}),
            _.merge(_.cloneDeep(height), {default: 200}),
            {
                name: 'top',
                default: 200,
                group: 'common',
                desc: '顶像素',
                type: 'number'
            },
            {
                name: 'left',
                default: 200,
                group: 'common',
                desc: '左像素',
                type: 'number'
            }
        ]
    })
)

PropertyDescriptionTable.set(
    'layout',
    new PropertyDescription({
        props: [
            {
                name: 'borderless',
                default: true,
                group: 'css',
                desc: '有无边框',
                type: 'boolean'
            },
            {
                name: 'type',
                default: '',
                group: 'css',
                desc: '布局类型',
                type: ['line', 'clean', 'wide', 'space', 'form']
            },
            {
                name: '_designMode',
                default: 'module',
                group: 'common',
                desc: '设计类型',
                type: ['none', 'module', 'scroll-module']
            }
        ]
    })
)

const YvBase: PropertyDescriptionInterface = {
    props: [
        {
            name: 'entityName',
            default: '',
            group: 'bind',
            desc: '实体类名',
            type: 'string'
        },
        {
            name: 'ctlName',
            default: '',
            group: 'bind',
            desc: '控件名',
            type: 'string'
        },
        {
            name: 'css',
            default: '',
            group: 'css',
            desc: '样式类名',
            type: 'string'
        },
        {
            name: 'attr',
            default: {},
            group: 'css',
            desc: 'HTML属性',
            type: 'object'
        },
        {
            name: 'render',
            default: true,
            group: 'common',
            desc: '是否显示',
            type: 'boolean'
        },
        {
            name: 'padding',
            default: undefined,
            group: 'css',
            desc: '内边距',
            type: 'object'
        },
        {
            name: 'margin',
            default: undefined,
            group: 'css',
            desc: '外边距',
            type: 'object'
        },
        {
            name: 'ff',
            default: 0,
            group: 'common',
            desc: '自动定焦时间',
            type: 'number'
        }
    ],
    events: [{name: 'onRender', desc: '第一次控件被渲染时触发'}]
}

const YvDataSource: PropertyDescriptionInterface = {
    props: [
        {
            name: 'type',
            default: '',
            group: 'data',
            desc: '数据源类型',
            type: 'dataSource'
        }
    ],
    events: [{name: 'onDataComplete', desc: '数据绑定完成后触发'}]
}

PropertyDescriptionTable.set(
    'template',
    new PropertyDescription(YvBase, {
        props: [
            template, width, height
        ]
    })
)

PropertyDescriptionTable.set(
    'text',
    new PropertyDescription(YvBase, {
        props: [
            label, labelAlign, labelWidth, gravity, hidden, readonly, disabled, required, value, prompt, validType, metaId, width, height
        ]
    })
)

PropertyDescriptionTable.set(
    'number',
    new PropertyDescription(YvBase, {
        props: [
            label, labelAlign, labelWidth, gravity, hidden, readonly, disabled, required, value, prompt, validType, metaId, width, height
        ]
    })
)

PropertyDescriptionTable.set(
    'date',
    new PropertyDescription(YvBase, {
        props: [
            label, labelAlign, labelWidth, gravity, hidden, readonly, disabled, required, value, prompt,
            {
                name: 'type',
                default: '',
                group: 'common',
                desc: '默认显示样式',
                type: ['year', 'month', 'none']
            },
            validType, metaId, width, height
        ]
    })
)

PropertyDescriptionTable.set(
    'datetime',
    new PropertyDescription(YvBase, {
        props: [
            label, labelAlign, labelWidth, gravity, hidden, readonly, disabled, required, value, prompt,
            {
                name: 'type',
                default: '',
                group: 'common',
                desc: '默认显示样式',
                type: ['year', 'month', 'none']
            },
            validType, metaId, width, height
        ]
    })
)

PropertyDescriptionTable.set(
    'search',
    new PropertyDescription(YvBase, {
        props: [
            label, labelAlign, labelWidth, gravity, hidden, readonly, disabled, required, value, prompt, validType, metaId, width, height,
            {
                name: 'widget',
                default: '',
                group: 'common',
                desc: '搜索弹窗',
                type: 'widget'
            }
        ]
    })
)

PropertyDescriptionTable.set(
    'fieldset',
    new PropertyDescription(YvBase, {
        props: [
            {
                name: 'label',
                default: '',
                group: 'common',
                desc: '字段组标题',
                type: 'string'
            }, width, height
        ]
    })
)

PropertyDescriptionTable.set(
    'combo',
    new PropertyDescription(YvBase, {
        props: [
            label, labelAlign, labelWidth, gravity, hidden, readonly, disabled, required, value, prompt,
            {
                name: 'dataSourceTreeLevel',
                default: '',
                group: 'common',
                desc: '树形标准级别',
                type: 'number'
            },
            {
                name: 'dataSourceTreeWatchEntity',
                default: '',
                group: 'common',
                desc: '联机下拉框中，关注的父下拉框实体',
                type: 'string'
            },
            validType, metaId, width, height
        ]
    })
)

PropertyDescriptionTable.set(
    'button',
    new PropertyDescription(YvBase, {
        props: [
            {
                name: 'text',
                default: '',
                group: 'common',
                desc: '按钮标题',
                type: 'string'
            },
            {
                name: 'icon',
                default: '',
                group: 'common',
                desc: '图标样式',
                type: 'string'
            },
            disabled, gravity, tooltip,
            {
                name: 'cssType',
                default: 'default',
                group: 'css',
                desc: '样式类型',
                type: ['default', 'primary', 'danger', 'success']
            }, width, height,
            onClick

        ],
        events: [{name: 'onClick', desc: '控件点击时触发'}]
    })
)

PropertyDescriptionTable.set(
    'checkbox',
    new PropertyDescription(YvBase, {
        props: [
            label, value, disabled,
            {
                name: 'labelAtRight',
                default: true,
                group: 'common',
                desc: '是否居右',
                type: 'boolean'
            },
            gravity, tooltip, metaId, width, height
        ],
        events: [{name: 'onChange', desc: '控件被修改时触发'}]
    })
)

PropertyDescriptionTable.set(
    'radio',
    new PropertyDescription(YvBase, {
        props: [
            label, value, disabled, gravity, tooltip, metaId, width, height
        ],
        events: [{name: 'onChange', desc: '控件被修改时触发'}]
    })
)

PropertyDescriptionTable.set(
    'label',
    new PropertyDescription(YvBase, {
        props: [
            label,
            {
                name: 'align',
                default: 'left',
                group: 'common',
                desc: '对齐方式',
                type: ['left', 'right', 'center']
            },
            disabled, gravity, _.merge(_.cloneDeep(width), {default: 100}), height
        ]
    })
)

PropertyDescriptionTable.set(
    'iframe',
    new PropertyDescription(YvBase, {
        props: [
            {
                name: 'src',
                default: '',
                group: 'common',
                desc: '地址路径',
                type: 'string'
            }, width, height
        ]
    })
)

PropertyDescriptionTable.set(
    'grid',
    new PropertyDescription(YvBase, {
        props: [
            {
                name: 'checkbox',
                default: '',
                group: 'common',
                desc: '是否多选',
                type: 'boolean'
            },
            {
                name: 'editable',
                default: '',
                group: 'common',
                desc: '是否允许编辑',
                type: 'boolean'
            },
            {
                name: 'clientFilter',
                default: '',
                group: 'common',
                desc: '是否为客户端过滤',
                type: 'boolean'
            },
            {
                name: 'clientSort',
                default: '',
                group: 'common',
                desc: '是否为客户端排序',
                type: 'boolean'
            },
            {
                name: 'useCrossPageCheck',
                default: '',
                group: 'common',
                desc: '允许跨页勾选',
                type: 'boolean'
            },
            {
                name: 'editSingleClick',
                default: '',
                group: 'common',
                desc: '单击后立刻进入编辑',
                type: 'boolean'
            },
            {
                name: 'allowNewRow',
                default: '',
                group: 'common',
                desc: '是否允许添加',
                type: 'boolean'
            },
            {
                name: 'filterable',
                default: '',
                group: 'common',
                desc: '是否允许过滤',
                type: 'boolean'
            },
            {
                name: 'showRowNumber',
                default: '',
                group: 'common',
                desc: '是否显示序号',
                type: 'boolean'
            },
            {
                name: 'autoSizeColumns',
                default: '',
                group: 'common',
                desc: '是否允许自动调整列宽',
                type: 'boolean'
            },
            {
                name: 'defaultUnselecteRow',
                default: '',
                group: 'common',
                desc: '默认不选中第一行',
                type: 'boolean'
            },
            {
                name: 'allowCellSelection',
                default: '',
                group: 'common',
                desc: '单元格选中模式',
                type: 'boolean'
            },
            {
                name: 'allowRowSelection',
                default: '',
                group: 'common',
                desc: '行选中模式',
                type: 'boolean'
            },
            {
                name: 'autoLoad',
                default: '',
                group: 'common',
                desc: '是否自动读取数据',
                type: 'boolean'
            },
            {
                name: 'pagination',
                default: 'true',
                group: 'common',
                desc: '是否分页',
                type: 'boolean'
            },
            {
                name: 'pageSize',
                default: '',
                group: 'common',
                desc: '是否允许编辑',
                type: 'number'
            }, width, height,
            onRowSelect
        ]
    })
)

PropertyDescriptionTable.set(
    'tree',
    new PropertyDescription(YvDataSource, YvBase, {
        props: [
            {
                name: 'showCheckbox',
                default: false,
                group: 'common',
                desc: '显示勾选',
                type: 'boolean'
            },
            {
                name: 'showLeftIcon',
                default: true,
                group: 'common',
                desc: '显示左侧图标',
                type: 'boolean'
            },
            {
                name: 'showIcon',
                default: true,
                group: 'common',
                desc: '显示图标',
                type: 'boolean'
            }, width, height
        ],
        events: [
            {name: 'onNodeClick', desc: '节点被点击后触发'},
            {name: 'onNodeDblClick', desc: '节点被双击后触发'}
        ]
    })
)

PropertyDescriptionTable.set(
    'uploader',
    new PropertyDescription(YvBase, {
        props: [
            width, height,
            {
                name: 'value',
                default: '上传',
                group: 'common',
                desc: '文本描述',
                type: 'string'
            },
            {
                name: 'upload',
                default: '/upload',
                group: 'common',
                desc: '上传地址',
                type: 'string'
            },

        ],
        events: [
            {name: 'onFileUpload', desc: '文件上传成功结束时触发'},
            {name: 'onFileUploadError', desc: '在上传过程中发生服务器端错误时触发'},
        ]
    })
)

PropertyDescriptionTable.set(
    'viewer',
    new PropertyDescription(YvBase, {
        props: [
            value,
            gravity,
            width, height,
            {
                name: 'imgWidth',
                default: '',
                group: 'common',
                desc: '图片宽',
                type: 'string'
            },
            {
                name: 'imgHeight',
                default: '',
                group: 'common',
                desc: '图片高',
                type: 'string'
            }
        ]
    })
)

PropertyDescriptionTable.set(
    'image',
    new PropertyDescription(YvBase, {
        props: [
            value,
            gravity,
            width, height,
            {
                name: 'imgWidth',
                default: '',
                group: 'common',
                desc: '图片宽',
                type: 'string'
            },
            {
                name: 'imgHeight',
                default: '',
                group: 'common',
                desc: '图片高',
                type: 'string'
            }
        ]
    })
)

PropertyDescriptionTable.set(
    'scrollview',
    new PropertyDescription(YvBase, {
        props: [
            width, height
        ]
    })
)